<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/5
 * Time: 12:25
 */

namespace App\Http\Controllers\MiniProgram;

use App\Http\Logics\MiniProgram\MarkLogic;
use App\Http\Traits\MarkTrait;
use App\Http\Controllers\BaseController;
class MarkController extends BaseController
{
    use MarkTrait;
    /**
     * @SWG\Post(
     *     path="/mark/create",
     *     tags={"Mark"},
     *     description="创建咖啡馆标签",
     *     operationId="createMark",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="标签名称",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createMark()
    {
        $name = $this->name;
        $data = [
            'name' => $name
        ];
        $response = MarkLogic::createMark($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/mark/list",
     *     tags={"Mark"},
     *     description="获取咖啡馆标签列表",
     *     operationId="getMarkList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="is_menu",
     *         in="query",
     *         description="是否是标签菜单",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="is_common",
     *         in="query",
     *         description="是否是公共标签",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getMarkList()
    {
        $is_menu = $this->is_menu;
        $is_common = $this->is_common;
        $limit = $this->limit;
        $data = [
            'is_menu' => $is_menu,
            'is_common' => $is_common,
            'limit' => $limit
        ];
        $response = MarkLogic::getMarkList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/mark/getMostList",
     *     tags={"Mark"},
     *     description="通过城市编码获取到使用最多的标签列表",
     *     operationId="getMostMarkList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="citycode",
     *         in="query",
     *         description="城市编码",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="show_num",
     *         in="query",
     *         description="显示个数,不能和limit参数一起使用",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="limit",
     *         in="query",
     *         description="分页限制",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getMostMarkList()
    {
        $citycode = $this->citycode;
        $show_num = $this->show_num;
        $limit = $this->limit;
        $data = [
            'citycode' => $citycode,
            'show_num' => $show_num,
            'limit' => $limit
        ];
        $response = MarkLogic::getMostMarkList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/mark/detail",
     *     tags={"Mark"},
     *     description="获取标签详情",
     *     operationId="getMarkDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="mark_id",
     *         in="query",
     *         description="标签ID",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getMarkDetail()
    {
        $mark_id = $this->mark_id;
        $data = [
            'mark_id' => $mark_id
        ];
        $response = MarkLogic::getMarkDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}